From 551ba1fdc91304559c064b5560eb3cc8e17bba4e Mon Sep 17 00:00:00 2001 From: tsteven4 <13596209+tsteven4@users.noreply.github.com> Date: Wed, 5 Feb 2020 18:45:52 -0700 Subject: [PATCH] miscellaneous cleanups (#496) * msvc, resharper fixes Some "Qualifier is redundant" "Redundant empty declaration" "Redundant empty statement" * restore missing comment * various corrections ... clazy clang-range-loop some casting that confuse clang-tidy google-readability-casting --- .gitignore | 2 ++ cst.cc | 2 +- defs.h | 28 ++++++++++++++-------------- filter_vecs.h | 6 +++--- garmin_fit.cc | 2 +- igo8.cc | 2 +- mmo.cc | 2 +- nmea.cc | 2 +- sort.cc | 2 +- 9 files changed, 25 insertions(+), 23 deletions(-) diff --git a/.gitignore b/.gitignore index 1ef1a9845..b75414fef 100644 --- a/.gitignore +++ b/.gitignore @@ -5,6 +5,7 @@ /config.log /config.status /cscope.out +/debug/ /gpsbabel /gpsbabel-debug /gpsbabel_coverage.xml @@ -25,6 +26,7 @@ /Makefile /makelinuxdist.sh /objects/ +/release/ *.swp /tmp/ /Makefile diff --git a/cst.cc b/cst.cc index 887465bba..57079349c 100644 --- a/cst.cc +++ b/cst.cc @@ -270,7 +270,7 @@ cst_data_read() track = route_head_alloc(); track_add_head(track); } else if (strncmp(name, "NAME:", 5) == 0) { - wpt->shortname = QString::fromLatin1(((char*)&name) + 5); + wpt->shortname = QString::fromLatin1(name + 5); } QString time_string(cin); diff --git a/defs.h b/defs.h index b1e456f8e..ed732d202 100644 --- a/defs.h +++ b/defs.h @@ -66,39 +66,39 @@ # define M_PI 3.14159265358979323846 #endif -constexpr double FEET_TO_METERS(double feetsies) { return (feetsies) * 0.3048; }; -constexpr double METERS_TO_FEET(double meetsies) { return (meetsies) * 3.2808399; }; +constexpr double FEET_TO_METERS(double feetsies) { return (feetsies) * 0.3048; } +constexpr double METERS_TO_FEET(double meetsies) { return (meetsies) * 3.2808399; } -constexpr double NMILES_TO_METERS(double a) { return a * 1852.0;}; /* nautical miles */ -constexpr double METERS_TO_NMILES(double a) { return a / 1852.0;}; +constexpr double NMILES_TO_METERS(double a) { return a * 1852.0;} /* nautical miles */ +constexpr double METERS_TO_NMILES(double a) { return a / 1852.0;} -constexpr double MILES_TO_METERS(double a) { return (a) * 1609.344;}; -constexpr double METERS_TO_MILES(double a) { return (a) / 1609.344;}; -constexpr double FATHOMS_TO_METERS(double a) { return (a) * 1.8288;}; +constexpr double MILES_TO_METERS(double a) { return (a) * 1609.344;} +constexpr double METERS_TO_MILES(double a) { return (a) / 1609.344;} +constexpr double FATHOMS_TO_METERS(double a) { return (a) * 1.8288;} -constexpr double CELSIUS_TO_FAHRENHEIT(double a) { return (((a) * 1.8) + 32);}; -constexpr double FAHRENHEIT_TO_CELSIUS(double a) { return (((a) - 32) / 1.8);}; +constexpr double CELSIUS_TO_FAHRENHEIT(double a) { return (((a) * 1.8) + 32);} +constexpr double FAHRENHEIT_TO_CELSIUS(double a) { return (((a) - 32) / 1.8);} constexpr long SECONDS_PER_HOUR = 60L * 60; constexpr long SECONDS_PER_DAY = 24L * 60 * 60; /* meters/second to kilometers/hour */ -constexpr double MPS_TO_KPH(double a) { return (a)*SECONDS_PER_HOUR/1000.0;}; +constexpr double MPS_TO_KPH(double a) { return (a)*SECONDS_PER_HOUR/1000.0;} /* meters/second to miles/hour */ -constexpr double MPS_TO_MPH(double a) { return METERS_TO_MILES(a) * SECONDS_PER_HOUR;}; +constexpr double MPS_TO_MPH(double a) { return METERS_TO_MILES(a) * SECONDS_PER_HOUR;} /* meters/second to knots */ -constexpr double MPS_TO_KNOTS(double a) { return MPS_TO_KPH((a)/1.852);}; +constexpr double MPS_TO_KNOTS(double a) { return MPS_TO_KPH((a)/1.852);} /* kilometers/hour to meters/second */ -constexpr double KPH_TO_MPS(double a) { return a * 1000.0/SECONDS_PER_HOUR;}; +constexpr double KPH_TO_MPS(double a) { return a * 1000.0/SECONDS_PER_HOUR;} /* miles/hour to meters/second */ #define MPH_TO_MPS(a) (MILES_TO_METERS(a) / SECONDS_PER_HOUR) /* knots to meters/second */ -constexpr double KNOTS_TO_MPS(double a) {return KPH_TO_MPS(a) * 1.852; }; +constexpr double KNOTS_TO_MPS(double a) {return KPH_TO_MPS(a) * 1.852; } #define MILLI_TO_MICRO(t) ((t) * 1000) /* Milliseconds to Microseconds */ #define MICRO_TO_MILLI(t) ((t) / 1000) /* Microseconds to Milliseconds*/ diff --git a/filter_vecs.h b/filter_vecs.h index 43fb1b6e6..b3489a7bc 100644 --- a/filter_vecs.h +++ b/filter_vecs.h @@ -82,9 +82,9 @@ void disp_filters(int version) const; bool validate_filters() const; private: -static void disp_help_url(const FilterVecs::fl_vecs_t& vec, const arglist_t* arg); -static void disp_v1(const FilterVecs::fl_vecs_t& vec); -static bool validate_filter_vec(const FilterVecs::fl_vecs_t& vec); +static void disp_help_url(const fl_vecs_t& vec, const arglist_t* arg); +static void disp_v1(const fl_vecs_t& vec); +static bool validate_filter_vec(const fl_vecs_t& vec); private: ArcDistanceFilter arcdist; diff --git a/garmin_fit.cc b/garmin_fit.cc index ca55c6ffb..f43c750f7 100644 --- a/garmin_fit.cc +++ b/garmin_fit.cc @@ -1263,7 +1263,7 @@ fit_collect_track_tlr(const route_head *rte) double best_odometer_distance = 0; for (auto cit = course.begin(); cit != course.end(); cit++) { if (!cit->is_course_point) { - double distance = gcgeodist(cit->lat, cit->lon, wpt.lat, wpt.lon);; + double distance = gcgeodist(cit->lat, cit->lon, wpt.lat, wpt.lon); if (best_distance < 0 || distance < best_distance) { best_distance = distance; best_distance_it = cit; diff --git a/igo8.cc b/igo8.cc index 4ba0f741c..9dbabccd9 100644 --- a/igo8.cc +++ b/igo8.cc @@ -258,7 +258,7 @@ static unsigned int print_unicode(char* dst, int dst_max_length, const QString& if (max_qchars < 1) { // We must have room for the terminator. fatal(MYNAME ": igo8 header overflow.\n"); - }; + } // Write as many characters from the source as possible // while leaving space for a terminator. int n_src_qchars = std::min(max_qchars - 1, src.size()); diff --git a/mmo.cc b/mmo.cc index 329e047cb..080d12c44 100644 --- a/mmo.cc +++ b/mmo.cc @@ -1047,7 +1047,7 @@ mmo_writestr(const QString& str) bool topbitset = false; // see if there's any utf-8 multi-byte chars - QByteArray utf8 = str.toUtf8(); + const QByteArray utf8 = str.toUtf8(); int len = utf8.size(); for (unsigned char byte : utf8) { if (byte & 0x80) { diff --git a/nmea.cc b/nmea.cc index 4b217ee95..167b0767f 100644 --- a/nmea.cc +++ b/nmea.cc @@ -814,7 +814,7 @@ pcmpt_parse(char* ibuf) dmy = hms = 0; sscanf(ibuf,"$PCMPT,%d,%d,%d,%c,%f,%d,%19[^,],%d,%f,%d,%f,%c,%d,%c,%d", - &j1, &j2, &j3, &altflag, &alt, &j4, (char*) &coords, + &j1, &j2, &j3, &altflag, &alt, &j4, coords, &j5, &f1, &j6, &f2, &u1, &dmy, &u2, &hms); if (altflag == 'D' && curr_waypt && alt > 0) { diff --git a/sort.cc b/sort.cc index 7f3f3df20..417520f17 100644 --- a/sort.cc +++ b/sort.cc @@ -89,7 +89,7 @@ void SortFilter::process() if (rte_sort_mode != SortModeRteHd::none) { switch (rte_sort_mode) { case SortModeRteHd::description: - route_sort(SortFilter::sort_comp_rh_by_description); + route_sort(sort_comp_rh_by_description); break; case SortModeRteHd::name: route_sort(sort_comp_rh_by_name); -- 2.30.2